package com.app.ctzoverseas.network.repo

import com.app.ctzoverseas.network.http.GoodsNetwork
import com.app.ctzoverseas.network.http.LoginNetwork
import com.cardetective.shopcar.network.model.AddCarPost
import com.cardetective.shopcar.network.model.BindMobilePost
import com.cardetective.shopcar.network.model.LoginPost

class GoodsRepo(private val network: GoodsNetwork) {

    fun getGoodsCategory(parentId: String) = network.getGoodsCategory(parentId)
    fun getGoodsListInfo(categoryId: String,pageNo:Int,pageSize:Int) = network.getGoodsList(categoryId,pageNo,pageSize)
    fun getGoodsDetail(goodsId: String) = network.getGoodsDetail(goodsId)
    fun getGoodsBySkuDetail(goodsId: String,goodsSkuId: String) = network.getGoodsBySkuDetail(goodsId, goodsSkuId)
    fun addCar(cartType: String,num: Int,skuId:String) = network.addCar(cartType, num, skuId)
    fun getCarData() = network.getCarData()
    fun checkAllGoodsCar(checked:Boolean) = network.checkAllGoodsCar(checked)
    fun checkedStoreCar(checked:Boolean,storeId:String) = network.checkedStoreCar(checked,storeId)
    fun updateGoodsInCar(num: Int,skuId: String) = network.updateGoodsInCar(num, skuId)
    fun deleteGoodsInCar(skuIds: String) = network.deleteGoodsInCar(skuIds)
    fun submitCarOrder(cartType: String) = network.submitCarOrder(cartType)
    fun checkedSingleGoodInCar(skuId: String,checked: Boolean) = network.checkedSingleGoodInCar(skuId, checked)
    fun calCarGoods(cartType: String) = network.calCarGoods(cartType)
    fun payment(payType: String,sn:String) = network.payment(payType, sn)

    companion object {

        @Volatile
        private var INSTANCE: GoodsRepo? = null

        fun getInstance(netWork: GoodsNetwork) =
            INSTANCE ?: synchronized(this) {
                INSTANCE ?: GoodsRepo(netWork).also { INSTANCE = it }
            }
    }
}